import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { createApp } from 'vue'
import VueAxios from 'vue-axios'
import axios from '../lib/axios'
import ContentApp from './home'


const app = createApp(ContentApp)

// 注册ElementPlusIconsVue
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(ElementPlus)

app.use(VueAxios, axios)

const ID = '__CONTENT_RESULE_ROOT__'
const root = document.createElement('div')
root.id = ID
// root.style.cssText = `bottom: calc(100vh - 500px); right: 0; position: fixed; z-index: 999999; `
// root.style.cssText = `top: 50%; right: 0; transform: translateY(-50%); position: fixed; z-index: 999999; `
document.body.appendChild(root)

/**
 * 触发页面的事件，以便页面中的脚本能够监听执行。
 * @param {Element} elt 要出发的元素
 * @param {string} evt 事件名称，不加on
 */
function firePageEvent(elt, evt) {
  var ev = document.createEvent("HTMLEvents")
  ev.initEvent(evt, true, true)
  elt.dispatchEvent(ev)
}

window.firePageEvent = firePageEvent

app.mount(`#${ID}`)
